import { request } from './index'
import { apiUrl } from './urlConfig'
//登录
interface logingParame {
  username: string,
  password: string,
  captcha: string,
  traceId: string
}
const login = function (parame: logingParame) {
  return request(apiUrl + "/auth/login", 'POST', parame);
}
// 获取user信息和权限
const getUserInfo = function () {
  return request(apiUrl + "/auth/userInfo", "GET");
}
//获取工艺名称数据字典
const findByTechNameDictionary = function (data: Array<object>) {
  return request(apiUrl + "/common/attachMore", "POST", data);
}
//生成工序任务
interface generateTechParame {
  taskNum: string,
  techName: string,
  equipmentNumber: string,
  partDrawingNumber: string,
  taskName: string,
  taskQuantity: string,
  techniqueStaff: string
}
const generateTechnique = function (params: generateTechParame) {
  return request(apiUrl + "/clockIn/generateTechnique", "POST", params);
}
//查询任务列表
interface findTaskListParame {
  state: number
}
const findTaskList = function (params: findTaskListParame) {
  return request(apiUrl + "/clockIn/findTaskList", "GET", params);
}
//查询详细信息
interface findProductDetailParame {
  techName: string,
  taskNum: string,
  equipmentNumber: string
}
const findProductDetail = function (params: findProductDetailParame) {
  return request(apiUrl + "/clockIn/findProductDetail", "POST", params);
}
//上机
interface upplaneParame {
  techniqueId: string,
  techName: string,
  partDrawingNumber: string,
  equipmentNumber: string,
  taskNum: string,
  operated: string,
}
let upplane = function (params: upplaneParame) {
  return request(apiUrl + "/clockIn/upplane", "POST", params)
}
//下机
interface deplaneParame {
  techniqueId: string,
  techName: string,
  taskNum: string,
  equipmentNumber: string,
  partDrawingNumber: string,
  output: number,
  operated: string,
}
let deplane = function (params: deplaneParame) {
  return request(apiUrl + "/clockIn/deplane", "POST", params);
}
//结束加工任务
interface executeParame {
  techName: string,
  taskNum: string,
  equipmentNumber: string,
}
let executeState = function (params: executeParame) {
  return request(apiUrl + "/clockIn/executeState", "POST", params);
}

export default { login, getUserInfo, findByTechNameDictionary, generateTechnique, findTaskList, findProductDetail, upplane, deplane, executeState }